feat: improve battery icon loading strategy#348
Merged
Conversation
Reviewer's GuideImplements a multi-stage battery icon loader that first attempts system theme icons (including dark variants), then falls back to built-in SVG resources with robust error handling, and fixes a resource path inconsistency in the PowerStatusWidget. Sequence diagram for improved battery icon loading strategysequenceDiagram
participant PowerStatusWidget
participant PowerApplet
participant QIcon
participant QSvgRenderer
participant m_batteryIcon
PowerStatusWidget->>PowerApplet: refreshBatteryIcon(iconStr)
PowerApplet->>QIcon: fromTheme(iconName)
alt Theme icon exists
QIcon-->>PowerApplet: themeIcon
PowerApplet->>m_batteryIcon: setPixmap(themeIcon.pixmap())
else Theme icon missing
PowerApplet->>QSvgRenderer: QSvgRenderer(fallbackPath)
alt fallbackPath invalid
PowerApplet->>QSvgRenderer: load(normalPath)
end
PowerApplet->>m_batteryIcon: setPixmap(rendered SVG)
end
Class diagram for updated PowerApplet and PowerStatusWidget icon logicclassDiagram
class PowerStatusWidget {
+void refreshIcon()
-m_iconWidget
-m_applet
}
class PowerApplet {
+void refreshBatteryIcon(QString icon)
-m_batteryIcon
}
class QIcon {
+static QIcon fromTheme(QString iconName)
+QPixmap pixmap(QSize size)
}
class QSvgRenderer {
+QSvgRenderer(QString path)
+bool isValid()
+void load(QString path)
}
PowerStatusWidget --> PowerApplet : uses
PowerApplet --> QIcon : uses
PowerApplet --> QSvgRenderer : uses
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
18202781743
approved these changes
Aug 7, 2025
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 18202781743, wjyrich The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
1. Modified battery icon loading to first try system theme icons before falling back to built-in resources 2. Added proper handling for dark theme variants by appending "-dark" suffix 3. Improved SVG renderer fallback logic when theme icons are not available 4. Fixed resource path inconsistency in PowerStatusWidget 5. Added proper error handling for invalid SVG files The changes improve icon loading reliability and maintainability by: - Supporting system theme icons which allows for better customization - Providing proper fallback mechanisms when theme icons are missing - Ensuring consistent behavior across light/dark themes - Fixing resource path inconsistencies between components feat: 改进电池图标加载策略 1. 修改电池图标加载逻辑,优先尝试系统主题图标,再回退到内置资源 2. 添加了对暗色主题变体的正确处理,通过添加"-dark"后缀 3. 改进了当主题图标不可用时的SVG渲染器回退逻辑 4. 修复了PowerStatusWidget中的资源路径不一致问题 5. 为无效SVG文件添加了适当的错误处理 这些改进通过以下方式提高了图标加载的可靠性和可维护性: - 支持系统主题图标,允许更好的自定义 - 当主题图标缺失时提供适当的回退机制 - 确保在亮/暗主题下行为一致 - 修复组件间的资源路径不一致问题 Pms: BUG-323767
20651e5 to
45b05b6
Compare
deepin pr auto review代码审查意见:
以上是针对代码审查的几点意见,希望能对您有所帮助。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The changes improve icon loading reliability and maintainability by:
feat: 改进电池图标加载策略
这些改进通过以下方式提高了图标加载的可靠性和可维护性:
Summary by Sourcery
Improve battery icon loading by leveraging system theme icons, supporting dark theme variants, and enhancing fallback logic while fixing resource path inconsistencies.
New Features:
Bug Fixes:
Enhancements: